<?php

class GroupPermission extends Auth_Controller{
	function __construct() {
		parent::Controller ();
		$this->myauth->execute_auth ();
		$this->load->model ( 'acl/GroupPermissionModel', '', TRUE );
		$this->load->model ( 'acl/ModuleModel', '', TRUE );
		$this->load->model ( 'acl/GroupsModel','',TRUE );
	}

	/**
	 * 权限分类及权限页面
	 */
	function index(){
		$data['groupid'] = $this->input->post('groupid',true);
		$data['groups'] = $this->GroupsModel->get_groups_id($data['groupid']);
		$data['gp'] = $this->GroupPermissionModel->get_grouppermission_groupid($data['groupid']);
		$data['mp'] = $this->ModuleModel->get_permission_module_all();
		$data['module'] = $this->ModuleModel->get_module_all();
		$this->load->view('acl/grouppermission',$data);
	}
	/**
	 * 组权限添加
	 */
	function add(){
		$data['groupid'] = $this->input->post('groupid',true);
		$this->GroupPermissionModel->del_grouppermission($data['groupid']);
		$pid = $this->input->post('pid',true);;
		$spl = explode("," , $pid );
		if($spl!=""&&count($spl)>1){
			for($i=0;$i<count($spl);$i++){
				for($j=$i;$j<count($spl);$j++){
					$data['pid'] = $spl[$j];
					if($spl[$j]!=0)
					$this->GroupPermissionModel->add_grouppermission($data);
					break;
				}
			}
		}
	}
}
?>
